package io;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;

public class TestSerializable {

	public static void main(String[] args) throws Exception {
		ser(); // 序列化
		dser(); // 反序列话
	}

	public static void ser() throws Exception {
		File file = new File(CharStreamWriteFile.filename);
		ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream(
				file));
		out.writeObject(new Students());
		out.close();
	}

	public static void dser() throws Exception {
		File file = new File(CharStreamWriteFile.filename);
		ObjectInputStream input = new ObjectInputStream(new FileInputStream(
				file));
		Object obj = input.readObject();
		input.close();
		System.out.println(obj);
	}
}
